import * as THREE from 'three'
import { ColorGUIHelper } from './GUIHelper'
import { GUI } from 'three/addons/libs/lil-gui.module.min.js'

export const addAmbientLight = function ({ color = 0xffffff, intensity = 1, gui, scene=window.threeScene } = {}) {
  const light = new THREE.AmbientLight(color, intensity)
  if (gui) {
    const container = document.querySelector('.gui-list')
    const gui = new GUI({ title: 'ambient light', container })
    gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('颜色')
    gui.add(light, 'intensity', 0, 5, 0.01).name('强度')
  }
  scene.add(light)
  return light
}
